const Koa = require('koa');
const app = new Koa();

app.use(async (ctx) => {
    let url = ctx.url;

    //从上下文中的request对象中获取
    let request = ctx.request;
    let reqQuery = request.query;
    let reqQueryString = request.querystring;

    //从上下文中直接获取
    let ctxQuery = ctx.query;
    let ctxQueryString = ctx.querystring;

    ctx.body = {
        url,
        reqQuery,
        reqQueryString,
        ctxQuery,
        ctxQueryString
    }
});

app.listen(8686, () => {
    console.log(`服务启动成功：http://localhost:8686`);
});